Add a way to lock individual accelerator paths. (#73207, reported by Havoc
authorMatthias Clasen <maclas@gmx.de>
Mon, 29 Dec 2003 00:38:50 +0000 (00:38 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 29 Dec 2003 00:38:50 +0000 (00:38 +0000)
Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path,
gtk_accel_map_unlock_path): Add a way to lock individual accelerator
paths.  (#73207, reported by Havoc Pennington)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
gtk/gtkaccelmap.c
gtk/gtkaccelmap.h

index afc77d985111d6a11fdb65783e2aa967cb242cd9..6f80a4bfc9e7427a861da988d70e8bdfeea7d6ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path, 
+       gtk_accel_map_unlock_path): Add a way to lock individual accelerator
+       paths.  (#73207, reported by Havoc Pennington)
+
 Sat Dec 27 23:17:56 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtktoolbar.c (slide_idle_handler): use CHILD_VISIBLE
index afc77d985111d6a11fdb65783e2aa967cb242cd9..6f80a4bfc9e7427a861da988d70e8bdfeea7d6ae 100644 (file)
@@ -1,3 +1,9 @@
+Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path, 
+       gtk_accel_map_unlock_path): Add a way to lock individual accelerator
+       paths.  (#73207, reported by Havoc Pennington)
+
 Sat Dec 27 23:17:56 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtktoolbar.c (slide_idle_handler): use CHILD_VISIBLE
index afc77d985111d6a11fdb65783e2aa967cb242cd9..6f80a4bfc9e7427a861da988d70e8bdfeea7d6ae 100644 (file)
@@ -1,3 +1,9 @@
+Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path, 
+       gtk_accel_map_unlock_path): Add a way to lock individual accelerator
+       paths.  (#73207, reported by Havoc Pennington)
+
 Sat Dec 27 23:17:56 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtktoolbar.c (slide_idle_handler): use CHILD_VISIBLE
index afc77d985111d6a11fdb65783e2aa967cb242cd9..6f80a4bfc9e7427a861da988d70e8bdfeea7d6ae 100644 (file)
@@ -1,3 +1,9 @@
+Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path, 
+       gtk_accel_map_unlock_path): Add a way to lock individual accelerator
+       paths.  (#73207, reported by Havoc Pennington)
+
 Sat Dec 27 23:17:56 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtktoolbar.c (slide_idle_handler): use CHILD_VISIBLE
index afc77d985111d6a11fdb65783e2aa967cb242cd9..6f80a4bfc9e7427a861da988d70e8bdfeea7d6ae 100644 (file)
@@ -1,3 +1,9 @@
+Mon Dec 29 01:36:22 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaccelmap.[hc]: (gtk_accel_map_lock_path, 
+       gtk_accel_map_unlock_path): Add a way to lock individual accelerator
+       paths.  (#73207, reported by Havoc Pennington)
+
 Sat Dec 27 23:17:56 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtktoolbar.c (slide_idle_handler): use CHILD_VISIBLE
index 3c319711f2cb7acb8d4a2866cbbb5c8668853980..a3370019d4ce515789c11dabbb9ea0e2b48568ad 100644 (file)
@@ -1,3 +1,7 @@
+Mon Dec 29 01:40:20 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtk-sections.txt: Add gtk_accel_map_{un,}lock_path.
+
 Wed Dec 24 01:12:12 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk-sections.txt: Add GtkClipboardTargetReceivedFunc,
index 709b7115b512710c4a9b994b7b1913837961bc16..4fcce87dcea720913240bda8e932d4a22f75bb49 100644 (file)
@@ -43,6 +43,7 @@ typedef struct {
   guint               std_accel_key;
   guint               std_accel_mods;
   guint        changed : 1;
+  guint        locked  : 1;
   GSList      *groups;
 } AccelEntry;
 
@@ -160,6 +161,7 @@ gtk_accel_map_add_entry (const gchar    *accel_path,
       entry->accel_key = accel_key;
       entry->accel_mods = accel_mods;
       entry->changed = FALSE;
+      entry->locked = FALSE;
       g_hash_table_insert (accel_entry_ht, entry, entry);
     }
 }
@@ -240,6 +242,7 @@ internal_change_entry (const gchar    *accel_path,
          entry->accel_key = accel_key;
          entry->accel_mods = accel_mods;
          entry->changed = TRUE;
+         entry->locked = FALSE;
        }
       return TRUE;
     }
@@ -251,6 +254,9 @@ internal_change_entry (const gchar    *accel_path,
        entry->changed = TRUE;
       return simulate ? TRUE : FALSE;
     }
+  
+  if (entry->locked)
+    return FALSE;
 
   /* nobody's interested, easy going */
   if (!entry->groups)
@@ -825,3 +831,57 @@ _gtk_accel_map_remove_group (const gchar   *accel_path,
 
   entry->groups = g_slist_remove (entry->groups, accel_group);
 }
+
+
+/**
+ * gtk_accel_map_lock_path:
+ * @accel_path: a valid accelerator path
+ * 
+ * Locks the given accelerator path.
+ *
+ * Locking an accelerator path prevents its accelerator to be changed 
+ * during runtime. A locked accelerator path can be unlocked by 
+ * gtk_accel_map_unlock_path(). Refer to gtk_accel_map_change_entry() 
+ * about runtime accelerator changes.
+ *
+ * Note that locking of individual accelerator paths is independent from 
+ * locking the #GtkAccelGroup containing them. For runtime accelerator
+ * changes to be possible both the accelerator path and its #GtkAccelGroup
+ * have to be unlocked. 
+ *
+ * Since: 2.4
+ **/
+void 
+gtk_accel_map_lock_path (const gchar *accel_path)
+{
+  AccelEntry *entry;
+
+  g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
+
+  entry = accel_path_lookup (accel_path);
+  
+  if (entry)
+    entry->locked = TRUE;
+}
+
+/**
+ * gtk_accel_map_unlock_path:
+ * @accel_path: a valid accelerator path
+ * 
+ * Unlocks the given accelerator path. Refer to gtk_accel_map_lock_path()
+ * about accelerator path locking.
+ *
+ * Since: 2.4
+ **/
+void 
+gtk_accel_map_unlock_path (const gchar *accel_path)
+{
+  AccelEntry *entry;
+
+  g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
+
+  entry = accel_path_lookup (accel_path);
+  
+  if (entry)
+    entry->locked = FALSE;  
+}
index 8b1e5fa669fc18ca21f1589c9019326bc211206c..9601b4bc4bb20f938645301ef83283153e5ff45e 100644 (file)
@@ -51,6 +51,8 @@ void     gtk_accel_map_load_fd        (gint                    fd);
 void      gtk_accel_map_load_scanner   (GScanner               *scanner);
 void      gtk_accel_map_save_fd        (gint                    fd);
 
+void       gtk_accel_map_lock_path      (const gchar            *accel_path);
+void       gtk_accel_map_unlock_path    (const gchar            *accel_path);
 
 /* --- filter functions --- */
 void   gtk_accel_map_add_filter         (const gchar           *filter_pattern);